Skip to content

Expose optional native error details for auth failures#886

Merged
bryceknz merged 10 commits into
FormidableLabs:mainfrom
KevinvdBurg:more-descriptive-error-messages
May 20, 2026
Merged

Expose optional native error details for auth failures#886
bryceknz merged 10 commits into
FormidableLabs:mainfrom
KevinvdBurg:more-descriptive-error-messages

Conversation

@KevinvdBurg
Copy link
Copy Markdown
Contributor

@KevinvdBurg KevinvdBurg commented Aug 23, 2023

Description

Surfaces underlying native authorization errors on error.nativeError while keeping error.message unchanged (e.g. Network error).

Apps can keep showing error.message to users and use error.nativeError when they want the lower-level cause for debugging or custom UI.

This revives the original Android improvement, updates it for the current package layout, and extends the same behavior to iOS.

Related: #861, #799.

Verification

  • Verified Android locally with the demo app by forcing the IdentityServer token endpoint to use https://expired.badssl.com.
  • Confirmed error.message stays Network error on both platforms.
  • Confirmed the demo can consume error.nativeError and surface the certificate/cause detail (see screenshots below).
  • Built and launched the iOS demo app, then verified the same broken token endpoint flow on iOS.
Android iOS
image image

@robwalkerco
Copy link
Copy Markdown
Contributor

Thanks for your PR @KevinvdBurg

I noticed that you only modified the error description for Android. Is iOS already providing this additional error information? If not, would you be able to update your PR to keep iOS and Android aligned?

@KevinvdBurg
Copy link
Copy Markdown
Contributor Author

Hi @robwalkerco,

I'm trying to open the iOS project, but I'm getting the following error 🤔
image

But also, I'm unsure where the iOS variant handleAuthorizationException is the naming is not consistent between the platforms. If you can point me to the right function, I can add it. :)

@carbonrobot carbonrobot added the needs-triage Waiting for a member of the team to confirm label May 2, 2024
@bryceknz
Copy link
Copy Markdown
Contributor

Thanks for this contribution, @KevinvdBurg!

I was able to verify the Android behavior locally, and the added cause detail makes the error much more useful for debugging.

I’m going to continue the work from here by bringing the branch up to date with the current repo structure and extending the same underlying-error detail to iOS as well.

I'll make sure to give you git credit when I merge it!

@bryceknz bryceknz removed the needs-triage Waiting for a member of the team to confirm label May 19, 2026
@bryceknz bryceknz requested a review from Copilot May 20, 2026 08:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds more actionable authorization failure messages by including underlying native error details (Android Throwable cause / iOS NSUnderlyingErrorKey) so JS-side errors are less vague for troubleshooting and UX decisions.

Changes:

  • iOS: Append the underlying NSError’s localized description to the error message when present.
  • Android: Append the AuthorizationException cause’s localized message to the error message when present.
  • Add a patch changeset describing the behavior change.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/react-native-app-auth/ios/RNAppAuth.m Extends iOS error message formatting to include NSUnderlyingErrorKey details when available.
packages/react-native-app-auth/android/src/main/java/com/rnappauth/RNAppAuthModule.java Extends Android authorization exception rejection messages to include the throwable cause details.
.changeset/fuzzy-ravens-explain.md Declares a patch release for the improved error messages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .changeset/fuzzy-ravens-explain.md Outdated
bryceknz added 2 commits May 20, 2026 10:47
Keep user-facing auth error messages unchanged while surfacing underlying native diagnostics through error.nativeError.
Document the separate nativeError debug field without suggesting native details belong in user-facing messages.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

@bryceknz is attempting to deploy a commit to the formidable-labs Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 20, 2026

🦋 Changeset detected

Latest commit: 9038a64

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
react-native-app-auth Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Pass Android nativeError metadata without dropping the original AuthorizationException, and align the changeset frontmatter with repo style.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated no new comments.

@bryceknz bryceknz changed the title Added a more descriptive error message for AuthorizationExceptions Expose optional native error details for auth failures May 20, 2026
@bryceknz bryceknz merged commit fc5d6dc into FormidableLabs:main May 20, 2026
2 checks passed
@github-actions github-actions Bot mentioned this pull request May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants